package com.ruoyi.web.controller.cangku;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cangku.domain.Cangku;
import com.ruoyi.cangku.service.ICangkuService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 仓库信息Controller
 *
 * @author ruoyi
 * @date 2023-05-18
 */
@Api(tags="仓库信息管理")
@RestController
@RequestMapping("/system/cangku")
public class CangkuController extends BaseController
{
    @Autowired
    private ICangkuService cangkuService;

    /**
     * 查询仓库信息列表
     */
    @ApiOperation("查询仓库信息")
//    @PreAuthorize("@ss.hasPermi('ckgl:ckxx:list')")
    @GetMapping("/list")
    public TableDataInfo list(Cangku cangku)
    {
        startPage();
        List<Cangku> list = cangkuService.selectCangkuList(cangku);
        return getDataTable(list);
    }

    /**
     * 导出仓库信息列表
     */
//    @PreAuthorize("@ss.hasPermi('system:cangku:export')")
    @Log(title = "仓库信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Cangku cangku)
    {
        List<Cangku> list = cangkuService.selectCangkuList(cangku);
        ExcelUtil<Cangku> util = new ExcelUtil<Cangku>(Cangku.class);
        util.exportExcel(response, list, "仓库信息数据");
    }

    /**
     * 获取仓库信息详细信息
     */
    @ApiOperation("获取仓库详细信息")
//    @PreAuthorize("@ss.hasPermi('system:cangku:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cangkuService.selectCangkuById(id));
    }

    /**
     * 新增仓库信息
     */
    @ApiOperation("新增仓库信息")
//    @PreAuthorize("@ss.hasPermi('system:cangku:add')")
    @Log(title = "仓库信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Cangku cangku)
    {
        return toAjax(cangkuService.insertCangku(cangku));
    }

    /**
     * 修改仓库信息
     */
    @ApiOperation("修改仓库信息")
//    @PreAuthorize("@ss.hasPermi('system:cangku:edit')")
    @Log(title = "仓库信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Cangku cangku)
    {
        return toAjax(cangkuService.updateCangku(cangku));
    }

    /**
     * 删除仓库信息
     */
    @ApiOperation("删除仓库信息")
//    @PreAuthorize("@ss.hasPermi('system:cangku:remove')")
    @Log(title = "仓库信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cangkuService.deleteCangkuByIds(ids));
    }
}
